<?php
namespace app\common\controller;

use think\Controller;
use think\Request;
use app\common\auth\Auth;
//use app\common\auth\User;
use think\Session;
use app\common\model\UserRole;


class Base extends Controller{

    protected $user = null;

    public function __construct(Request $request){
        //获取权限标志
        $mark = $request->module().'/'.$request->controller().'/'.$request->action();
        $mark = strtolower($mark);
        $this->user = Session::get(config("sessionKey.loginUserKey"));
        if(!$this->user) $this->user = [];

        $auth = new Auth();
        $passport  = $auth->checkAuth($mark,$this->user);

        $defaultIndex = config("defaultIndex");
        if(!$passport && $mark !== $defaultIndex){
            $this->error("对不起，权限不够",$defaultIndex);
        }

    }
}